/* eslint-disable guard-for-in */
/* eslint-disable no-restricted-syntax */
/* eslint-disable @typescript-eslint/no-explicit-any */
const snake2camel = (data: any): any => {
  if (typeof data !== 'object' || !data) {
    return data;
  }
  if (Array.isArray(data)) {
    return data.map((item) => snake2camel(item));
  }
  const newData: any = {};
  for (const key in data) {
    const newKey = key.replace(/(_[a-z])/g, (p, m) => `${m.replace('_', '').toUpperCase()}`);
    newData[newKey] = snake2camel(data[key]);
  }
  return newData;
};
export default snake2camel;
